﻿using System;
using System.Linq;
using AutoR.Models;
using AutoR.Services;
using Prism.Commands;
using Prism.Mvvm;
using Prism.Navigation;
using Prism.Services;

namespace AutoR.ViewModels.Home
{
	// Token: 0x020000B6 RID: 182
	public class ExplorerViewModel : BindableBase, INavigationAware, INavigatedAware, INavigatingAware
	{
		// Token: 0x170000F5 RID: 245
		// (get) Token: 0x06000390 RID: 912 RVA: 0x00049E83 File Offset: 0x00048083
		private INavigationService NavigationService { get; }

		// Token: 0x170000F6 RID: 246
		// (get) Token: 0x06000391 RID: 913 RVA: 0x00049E8B File Offset: 0x0004808B
		private IPageDialogService PageDialogService { get; }

		// Token: 0x170000F7 RID: 247
		// (get) Token: 0x06000392 RID: 914 RVA: 0x000408F6 File Offset: 0x0003EAF6
		public GameData Game
		{
			get
			{
				return Runtime.Game;
			}
		}

		// Token: 0x170000F8 RID: 248
		// (get) Token: 0x06000393 RID: 915 RVA: 0x000444F1 File Offset: 0x000426F1
		public AllConfigs Configs
		{
			get
			{
				return Runtime.Configs;
			}
		}

		// Token: 0x170000F9 RID: 249
		// (get) Token: 0x06000394 RID: 916 RVA: 0x00049E93 File Offset: 0x00048093
		public DelegateCommand<string> ModifyExploreCommand { get; }

		// Token: 0x170000FA RID: 250
		// (get) Token: 0x06000395 RID: 917 RVA: 0x00049E9B File Offset: 0x0004809B
		public DelegateCommand<string> CancelExploreCommand { get; }

		// Token: 0x170000FB RID: 251
		// (get) Token: 0x06000396 RID: 918 RVA: 0x00049EA3 File Offset: 0x000480A3
		public DelegateCommand<UserShip> ChangeShipCommand { get; }

		// Token: 0x170000FC RID: 252
		// (get) Token: 0x06000397 RID: 919 RVA: 0x00049EAB File Offset: 0x000480AB
		public DelegateCommand<UserFleet> AddShipCommand { get; }

		// Token: 0x06000398 RID: 920 RVA: 0x00049EB4 File Offset: 0x000480B4
		public ExplorerViewModel(INavigationService navigationService, IPageDialogService pageDialogService)
		{
			this.NavigationService = navigationService;
			this.PageDialogService = pageDialogService;
			this.ModifyExploreCommand = new DelegateCommand<string>(async delegate(string s)
			{
				string text = await this.PageDialogService.DisplayActionSheetAsync("远征节点", "取消", "", new string[]
				{
					"1-1",
					"1-2",
					"1-3",
					"1-4",
					"2-1",
					"2-2",
					"2-3",
					"2-4",
					"3-1",
					"3-2",
					"3-3",
					"3-4",
					"4-1",
					"4-2",
					"4-3",
					"4-4",
					"5-1",
					"5-2",
					"5-3",
					"5-4",
					"6-1",
					"6-2",
					"6-3",
					"6-4",
					"7-1",
					"7-2",
					"7-3",
					"7-4"
				});
				if (text != "取消" && text != "")
				{
					int[] nextExplore = this.Game.ExploreTask.NextExplore;
					nextExplore[int.Parse(s)] = int.Parse(text.Replace("-", "000"));
					this.Game.ExploreTask.NextExplore = nextExplore.ToArray<int>();
				}
			});
			this.CancelExploreCommand = new DelegateCommand<string>(async delegate(string s)
			{
				if (this.Game.PVEExplore.Any((UserExplore i) => i.fleetId == int.Parse(s)))
				{
					UserExplore userExplore = this.Game.PVEExplore.Single((UserExplore i) => i.fleetId == int.Parse(s));
					this.Game.ExploreTask.CancelQueue.Enqueue(userExplore.exploreId);
					await this.PageDialogService.DisplayAlertAsync("提示", "停止远征请求加入队列", "确定");
				}
			});
			this.ChangeShipCommand = new DelegateCommand<UserShip>(async delegate(UserShip s)
			{
				await this.NavigationService.NavigateAsync("ShipConfig", new NavigationParameters
				{
					{
						"ship",
						s
					}
				});
			});
			this.AddShipCommand = new DelegateCommand<UserFleet>(async delegate(UserFleet s)
			{
				if (s.ships.Count < 6)
				{
					await this.NavigationService.NavigateAsync("AddShip", new NavigationParameters
					{
						{
							"fleet",
							s
						}
					});
				}
			});
		}

		// Token: 0x06000399 RID: 921 RVA: 0x0004067F File Offset: 0x0003E87F
		public void OnNavigatedFrom(INavigationParameters parameters)
		{
		}

		// Token: 0x0600039A RID: 922 RVA: 0x0004067F File Offset: 0x0003E87F
		public void OnNavigatedTo(INavigationParameters parameters)
		{
		}

		// Token: 0x0600039B RID: 923 RVA: 0x0004067F File Offset: 0x0003E87F
		public void OnNavigatingTo(INavigationParameters parameters)
		{
		}
	}
}
